﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Animation;

namespace RytmSerca.Converters
{
    public class BooleanToVisibilityParametrizedConverter : IValueConverter
    {
        private static readonly IValueConverter instance = new BooleanToVisibilityParametrizedConverter();

        public static IValueConverter Instance
        {
            get { return instance; }
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool) value
                       ? Visibility.Visible
                       : (Visibility) (parameter ?? Visibility.Collapsed);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    } 
    public class BooleanToRepeatBehaviourConverter : IValueConverter
    {
        private static readonly IValueConverter instance = new BooleanToRepeatBehaviourConverter();

        public static IValueConverter Instance
        {
            get { return instance; }
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool) value
                       ? RepeatBehavior.Forever
                       : new RepeatBehavior(1);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}